<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //合并数组
        let arr = [1, 34, 6, 7];
        let arr1 = [2, 4, 61, 8];
        let arr2 = [...arr, ...arr1];
        console.log(arr2);
        console.log(arr)


        //伪数组转为数组
        let set = new Set([1, 3, 4, 6]);
        let set1 = [...set];
        console.log(set);
        console.log(set1);

        //数组浅拷贝
        let arr5 = [1, 2, 3, ["张三", "李四"]];
         let  arr3=[...arr5];
         console.log(arr3);
         arr5[2]=6;
         console.log(arr5);
         console.log(arr3);
         arr5[3][1]="张伟";//互相影响
         console.log(arr5,arr3);




         //对象浅拷贝
         let obj = {
            name: "张三",
            age: 18,
            hobbies: ["吃", "喝"]
        }
         let obj1={...obj};
        console.log(obj1);
        obj.name="张伟";//不影响
        console.log(obj1);
        obj.hobbies[1]="打";//如果对象里面还有对象或者数组,那里面的对象或者数组变，拷贝的也跟着变
        console.log(obj1);
    </script>
</body>

</html>